/**
 * 
 */
package cn.dgfy.MyBatisStudy.plugin;

import java.util.Properties;

import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;

/**
 * @author Tearfalls
 *
 */
@Intercepts({
	@Signature(
			type = org.apache.ibatis.executor.statement.StatementHandler.class, 
			method = "parameterize", 
			args = java.sql.Statement.class
	)
})
public class MySecondPlugin implements Interceptor {
	
	@Override
	public Object intercept(Invocation invocation) throws Throwable {
		
		System.out.println("MySecondPlugin : intercept(Invocation invocation) : invocation.getMethod() = " + invocation.getMethod());
		
		Object proceed = invocation.proceed();
		
		return proceed;
	}
	
	@Override
	public Object plugin(Object target) {
		
		System.out.println("MySecondPlugin : plugin(Object target) : target = " + target);
		
		Object wrap = Plugin.wrap(target, this);
		
		System.out.println("MySecondPlugin : plugin(Object target) : wrap = " + wrap);
		
		return wrap;
	}
	
	@Override
	public void setProperties(Properties properties) {
		System.out.println("MySecondPlugin : setProperties(Properties properties) : properties = " + properties);
	}
	
}
